/**
 * Created by Administrator on 2016/12/16.
 */
/*解析href*/
var str = location.search;
str = str.slice(1).split('&');
var json = {};
for (var i = 0; i < str.length; i++) {
    var a = str[i].split('=');
    json[a[0]] = a[1];
}
//console.log(json);

$(function () {
    /*初始化*/
    init();
});
/*layer弹框效果*/
function ifrLayer (element , url){
    element.on("click", '', function() {
        layer.open({
            type: 2,
            maxmin: false,
            shadeClose: false,
            closeBtn: 1,
            area : ['100%' , '100%'],
            content:url,
            title :　false,
        });
    });
}

var oUrl = `http://192.168.59.3:8082/console/shopping/platformFac?projectCode=${json.projectCode}&pageNum=1&pageSize=10`
function init(){
    $('#workTable,#workTable1').bootstrapTable({
        method : 'get',  //发送方式
        url : oUrl,
        onLoadSuccess : function () {

        }
    })
}
/*回调函数*/
function responseHandler(res) {

    var needData = {
        rows: res.data.list,
        total: res.data.total
    };

    return needData;
}
/*每页序号*/
function indexFmt(val,row,index){
    return index+1;
}
/*分页器*/
function workTableQuery(params){
    params["pageNum"] = (params.offset / params.limit) + 1;
    params.pageSize = params.limit;
    return params;
}
function handlerFmt(value,row){
    //console.log(row);
    return `<button onclick="getDetail('${row.shopId}')"><span class="icon icon-caret-down"></span></button>`
}
function getDetail(code1,code2,code3){
    layer.open({
        type: 2,
        maxmin: false,
        shadeClose: false,
        closeBtn: 1,
        area : ['100%' , '100%'],
        content:`../platform-detail-f/platform-detail-f2.html?projectCode=${json.projectCode}&shopId=${code1}`,
        title :　false
    });
}


/*弹框*/
ifrLayer($('#ifr-worker'),`../Worker-attendance/Worker-attendance.html?projectCode=${json.projectCode}`);/*工人出勤 弹框*/
ifrLayer($('#ifr-self'),`../materiel-consume/materiel-consume.html?projectCode=${json.projectCode}`);/*自有物料 弹框*/
ifrLayer($('#pc1'),`../platform-consume/platform-consume.html?projectCode=${json.projectCode}`);/*平台物料-材料 弹框*/
ifrLayer($('#pe2'),`../platform-equipment/platform-equipment.html?projectCode=${json.projectCode}`);/*平台物料-设施 弹框*/
ifrLayer($('#purchaser'),`platform-facility.html?projectCode=${json.projectCode}`);/*平台物料-设施 弹框*/
